﻿using System;

namespace Medora.Core
{
   public class Translator
    {
   
        private static Translator _instance = null;
        private static readonly object locker = new object();
       
        public static Translator Instance
        {
            get
            {
                lock (locker)
                {
                    return _instance ?? (_instance = new Translator());
                }
            }
        }

        public string Translate(string key)
        {
            return Translate(key,key);
        }

        public string Translate(string key, string defaultValue)
        {
            var text = (string)System.Web.HttpContext.GetGlobalResourceObject(Utils.ApplicationName, key);
            return !String.IsNullOrEmpty(text) ? text : defaultValue;
        }
    }
}
